<template>
	<div class="zhengtuojianhuo">
		<van-nav-bar :fixed="true" class="navBar" title="按店拣货" left-arrow @click-left="$router.go(-1)"></van-nav-bar>

		<div class="goodsFromWarp">

				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">位置：</div>
						</div>

						<div class="skuNoInput">
							{{editForm.hqpbdq}}
						</div>

						<div class="searchBtn">
							<button :disabled="isdisabled"  @click.stop="_getAddressBtn()" >
								<van-icon name="search" size="20" color="#1989fa"  />
							</button>
						</div>
				</div>

				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">当前门店：</div>
						</div>



						<div class="skuNoInput">
							{{editForm.ck_storeid}} {{editForm.ck_storeid>''?'-':''}} {{editForm.storename}}
						</div>

				</div>


				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">商品名称：</div>
						</div>

						<div class="skuNoInput">
							{{editForm.subsname}}
						</div>
				</div>


				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">商品编码：</div>
						</div>

						<div class="skuNoInput">
							{{editForm.itemid}}
						</div>

						<div class="searchBtn">
							<button :disabled="isdisabled">
								<van-icon name="arrow-up" 	v-if="px =='Y'" @click="px = 'N'"	size="20" color="#1989fa"  />
								<van-icon name="arrow-down" v-if="px =='N'" @click="px = 'Y'" size="20" color="#1989fa" />
							</button>
						</div>

				</div>




				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">仓位编码：</div>
						</div>

						<div class="skuNoInput">
							{{editForm.cwno}}
						</div>
				</div>

				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">商品条码：</div>
						</div>

						<div class="skuNoInput">
							{{editForm.barcode}}
						</div>
				</div>


				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">分配箱装：</div>
						</div>


						<div class="skuNoInput">
								{{editForm.unit}}
						</div>

						<div class="goodsInputLabel">
							<div class="skuName">箱数：</div>
						</div>

						<van-field
							 v-if="addmode"
							 class="skuInput"
							 v-model="editForm.pack"
							 placeholder="请输入箱数"
						 />

						<div class="skuNoInput" v-if="!addmode">
							{{editForm.pack}}
						</div>
				</div>

				<div class="goodsInputWarp">

						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">总数量：</div>
						</div>


						<div class="skuNoInput">
							{{editForm.yjtotqty}}
						</div>

						<div class="goodsInputLabel">
							<!-- <div class="goodsInputBorder"></div> -->
							<div class="skuName">散数：</div>
						</div>

						<van-field
							 v-if="addmode"
							 class="skuInput"
							 v-model="editForm.qty"
							 placeholder="请输入散数"
						 />

						<div class="skuNoInput"  v-if="!addmode">
								{{editForm.qty}}
						</div>
				</div>


				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">拣货容器：</div>
						</div>

						<div class="skuNoInput">
								{{skuData[index].jhrq}}
						</div>

						<div class="searchGoodsBtn"  v-if="!addmode"  >
							<button  :disabled="isdisabled"  @click.stop="_selectSku()" >换商品</button>
						</div>
				</div>


				<scan-input
					 v-if="!addmode"
					 :item-id="editForm.itemid"
					 :cwno="editForm.cwno"
					 :operator-id="ryuser.operatorid"
					 :kq-id="ryuser.kqid"
					 @both-scanned="onBothScanned"
					 ref="scanInput"
				/>

		</div>


		<div class="skuBtn">
			<van-button type="info" :disabled="isdisabled" @click="lingquBtn()">领取任务</van-button>
			<van-button type="info" :disabled="saveSkuDisabled" @click="isSubmitVisible = true">拣货确认</van-button>
		</div>

		<div class="skuBtn">
			<van-button type="info"  v-if="!addmode" @click="editSkuClick()">修改</van-button>
			<van-button type="info"  v-if="addmode" @click="saveSkuBtnClick()">确认修改</van-button>
			<van-button type="info"  :disabled="addmode"  @click="overRongQiBtnClick()">结束容器</van-button>
		</div>

		<van-overlay :show="isLingQuVisible" :lock-scroll="false">
			<div class="shipandanWrapper">
					<van-sticky>
						<van-nav-bar class="navBar" title="仓位列表" left-arrow @click-left="isLingQuVisible = false"></van-nav-bar>
					</van-sticky>
					<div class="shipandanCon" @click.stop>
							<div  v-for="(row,i) in lingquData" :key="i" class="danjuRow" style="margin-top: 0px;"  @click="lingquClick(row)">
								<van-row class="skuList">
								  <van-col span="24"> <span>任务号：</span> {{row.bill}}</van-col>
								</van-row>

								<van-row class="skuList" >
								  <van-col span="24"> <span>仓位：</span> {{row.cwno}}</van-col>
								</van-row>

								<van-row class="skuList"  >
									<van-col span="24"> <span>拼接仓位：</span> {{row.cwnop}}</van-col>
								</van-row>

								<van-row class="skuList"  >
									<van-col span="24"> <span>仓位顺序号：</span> {{row.route_c}}</van-col>
								</van-row>

								<van-row class="skuList"  >
									<van-col span="12"> <span>集货位：</span> {{row.wno}}</van-col>
									<van-col span="12"> <span>仓库：</span> {{row.whsid}}</van-col>
								</van-row>

								<van-row class="skuList"  >
									<van-col span="12"> <span>区：</span> {{row.q_no}}</van-col>
									<van-col span="12"> <span>排：</span> {{row.p_no}}</van-col>
								</van-row>

								<van-row class="skuList"  >
									<van-col span="12"> <span>出货总量：</span> {{row.yjtotqty}}</van-col>
									<van-col span="12"> <span>托盘总量：</span> {{row.tqty}}</van-col>
								</van-row>

							</div>
					</div>
			</div>
		</van-overlay>


		<table-popup
			v-model="isSkuVisible"
			title="商品列表"
			:table-data="skuData"
			:columns="skuColumns"
			@select="selectSkuClick"
		/>

		<!-- 新的位置信息弹窗 -->
		<table-popup
			v-model="isAddressVisible"
			title="位置信息"
			:table-data="addressItem"
			:columns="addressColumns"
			@select="selectAddressClick"
		/>

    <!-- 提交确认 -->
    <van-overlay :show="isSubmitVisible" :lock-scroll="false">
          <div class="submitConfirmWrapper">
              <div class="submitConfirmHeader">
                <div class="submitConfirmHeaderLabel">拣货确认</div>
              </div>
              <div class="submitConfirmContent">
                  <div class="submitConfirmContentLabel">库区: {{ryuser.kqid}}请确认拣货完成:</div>
                  <div class="submitConfirmContentLabel">输入条码: {{editForm.barcode}}</div>
                  <div class="submitConfirmContentLabel">任务: {{activeIndex + 1}}/{{skuData.length}} 条,当前门店:{{editForm.ck_storeid}}-{{editForm.storename}}</div>
                  <div class="submitConfirmContentLabel">商品: {{editForm.subsname}} {{editForm.username}}</div>
                  <div class="submitConfirmContentLabel">实箱装: {{editForm.unit}} 箱:{{editForm.pack}} 散:{{editForm.qty}} 总数:{{(Number(editForm.unit) * Number(editForm.pack)) + Number(editForm.qty)}} {{ quantityDifference }}</div>

                  <div class="submitConfirmContentLabel">
                    已经拣货完成，是否确认?
                  </div>
              </div>
              <div class="submitConfirmFooter">
                <van-button type="info" @click="cancelSubmitConfirm()" style="background-color: #fff;color: #000;">取消</van-button>
                <van-button type="info" v-debounce:1000="_saveSku">提交</van-button>  <!-- 1秒内只能点击一次 -->
              </div>
          </div>
    </van-overlay>

	</div>
</template>

<script>
import ScanInput from '@/components/ScanInput.vue'
import TablePopup from '@/components/TablePopup.vue'

export default {
  name: 'storejh',
  components: {
    ScanInput,
    TablePopup
  },
  data() {
    return {
			editForm:{
				hqpbdq:'',
				td_no:'',
				ck_storeid:'',
				storename:'',
				cwno:'',
				unit:'',
				pack:'',
				qty:'',
				yjtotqty:'',
				subsname:'',
				username:'',
				barcode:'',
				bill:'',
				itemid:'',
				subid:'',
				jhrq:'',
				rwbill:'',
			},
			px:'Y',  //商品排序字段
			isdisabled:false,
			lingquData:[],
			isLingQuVisible:false,
			skuData:[
				{
					subsname	:'',
					ck_storeid	:'',
					storename	:'',
					jhrq:'',
				}
			],
			isSkuVisible:false,
			index:0,
			isAddressVisible:false,
			addressItem:[],
			addmode:false,
			unit1:'',
			qty1:'',
			verifyForm:{
				itemid:'',
				cwno:'',
				barcode:'',
				bill:'',
			},
			jieshuData:[],
			errorMessage:'',
			isValid:true,
			firstValidation:1,
      saveSkuDisabled:true, checkedItem :'', checkedCwno :'', _saveSku_runing:false,// 扫码验证的商品, 和 仓位
      isSubmitVisible:false, 
      activeIndex:0,
      currentIndex: -1, // 添加 currentIndex 用于跟踪当前选中行
			addressColumns: [
				{ prop: 'hqpbdq', label: '货区排单', width: '230' },
				{ prop: 'ck_storeid', label: '门店', width: '80' },
				{ prop: 'ylmxts', label: '数量', width: '70' },
				{ prop: 'cwno_f', label: '仓位自', width: '100' },
				{ prop: 'cwno_t', label: '仓位止', width: '100' }
			],
			skuColumns: [
				{ prop: 'subsname', label: '商品名称', width: '230' },
				{ prop: 'itemid', label: '商品编码', width: '120' },
				{ prop: 'cwno', label: '仓位', width: '100' },
				{ prop: 'unit', label: '箱装', width: '70' },
				{ prop: 'pack', label: '箱数', width: '70' },
				{ prop: 'qty', label: '散数', width: '70' },
				{ prop: 'yjtotqty', label: '总数量', width: '80' }
			],
		};
  },
	computed: {
	   ryuser: function(){
	     return this.GWO(true).gUSER;
	   },
	   quantityDifference() {
	     const yjtotqty = Number(this.editForm.yjtotqty) || 0
	     const unit = Number(this.editForm.unit) || 0
	     const pack = Number(this.editForm.pack) || 0
	     const qty = Number(this.editForm.qty) || 0

	     return yjtotqty === (unit * pack + qty) ? '[无差异]' : '[已修正]'
	   }
	},
  methods: {
		onBothScanned(pm_checkedItem,pm_checkedCwno) {
			// 商品和仓位都验证通过后的处理
			// this._saveSku()
      this.saveSkuDisabled = false;  this.checkedItem = pm_checkedItem; this.checkedCwno = pm_checkedCwno
      this.isSubmitVisible = true
		},
		_selectSku(){
			if(this.skuData[0].subsname >''){
					this.isSkuVisible = true
			}
		},
		_getSku(){
			if(this.editForm.cwno >''){

			}else{
				return this.$toast.fail('请先领取任务')
			}
			let sendData = {
				'kqid':this.ryuser.kqid,
				'czyid':this.ryuser.operatorid,
				'cwno':this.editForm.cwno,
				'storeid':this.editForm.storeid,
				'unit':this.editForm.unit,
				'whsid':this.editForm.whsid,
				'itemid':this.editForm.itemid,
				'subid':this.editForm.subid,
			}
			console.log(sendData)
			var _self = this;
				var ldemodata = [{retval:0, errmsg:'返回数据集'},]
				this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_jianhuo',
					'i':this.FNULLE([
					'opmode','Y_JTBH_qryitemid',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'cwno',this.editForm.cwno,
					'storeid',this.editForm.storeid,
					'unit',this.editForm.unit,
					'whsid',this.editForm.whsid,
					'itemid',this.editForm.itemid,
					'subid',this.editForm.subid,
					])
					},'获取商品详情',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
						_self.$toast.fail('查询失败')
						_self.$store.commit('hideLoading');
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}
						console.log("得到商品详情")
						console.log(rtn_json_obj)
						_self.skuData = rtn_json_obj
						console.log("得到获取商品详情")
						console.log(rtn_json_obj[0])
						if(_self.skuData.length > 0){
							// _self.isSkuVisible = true
						}else{
							_self.$toast.fail('暂无获取商品详情')
						}
					}
				});
		},
		lingquItem(){
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_jianhuo',
				'i':this.FNULLE([
				'opmode','Y_YJ_itemid',
				'czyid',this.ryuser.operatorid,
				'kqid', this.ryuser.kqid,
				'itemid',this.verifyForm.bill,
				])
				},'领取任务itemID',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log('领取任务itemID')
					console.log(rtn_json_obj[0])
					_self.verifyForm.bill = rtn_json_obj[0].itemid
				}
			});
		},
		lingquBtn(){
			if(this.editForm.hqpbdq >''){

			}else{
				return this.$dialog.alert({
						title: '注意',
						message: '请先选择位置后再领取任务',
				});
			}
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_jianhuo',
				'i':this.FNULLE([
				'opmode','Y_ANDIAN_lqbill',
				'czyid',this.ryuser.operatorid,
				'kqid', this.ryuser.kqid,
				'ck_storeid',this.editForm.ck_storeid,
				'td_no',this.editForm.td_no,
				'rwbill',this.editForm.rwbill,
				'px',this.px,
				])
				},'领取任务',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					_self.skuData = rtn_json_obj
					console.log("得到领取任务")
					console.log(rtn_json_obj)
					if(rtn_json_obj[0].ret_ret == '-1'){
						_self.editForm.ck_storeid 		= _self.skuData[0].ck_storeid
						_self.editForm.storename 			= _self.skuData[0].storename
						_self.editForm.cwno 					= _self.skuData[0].cwno
						_self.editForm.unit 					= _self.skuData[0].unit
						_self.editForm.pack 					= _self.skuData[0].pack
						_self.editForm.qty 						= _self.skuData[0].qty
						_self.editForm.yjtotqty 			= _self.skuData[0].yjtotqty
						_self.editForm.subsname 			= _self.skuData[0].subsname
						_self.editForm.username 			= _self.skuData[0].username
						_self.editForm.barcode 				= _self.skuData[0].barcode
						_self.editForm.bill 					= _self.skuData[0].bill
						_self.editForm.itemid 				= _self.skuData[0].itemid
						_self.editForm.subid 					= _self.skuData[0].subid
						_self.editForm.jhrq 					= _self.skuData[0].jhrq
						return _self.$toast(rtn_json_obj[0].ret_mess)
					}else{
							_self.editForm.ck_storeid 		= _self.skuData[0].ck_storeid
							_self.editForm.storename 			= _self.skuData[0].storename
							_self.editForm.cwno 					= _self.skuData[0].cwno
							_self.editForm.unit 					= _self.skuData[0].unit
							_self.editForm.pack 					= _self.skuData[0].pack
							_self.editForm.qty 						= _self.skuData[0].qty
							_self.editForm.yjtotqty 			= _self.skuData[0].yjtotqty
							_self.editForm.subsname 			= _self.skuData[0].subsname
							_self.editForm.username 			= _self.skuData[0].username
							_self.editForm.barcode 				= _self.skuData[0].barcode
							_self.editForm.bill 					= _self.skuData[0].bill
							_self.editForm.itemid 				= _self.skuData[0].itemid
							_self.editForm.subid 					= _self.skuData[0].subid
							_self.editForm.jhrq 					= _self.skuData[0].jhrq
							_self.$refs.scanInput.focus();
					}
				}
			});
		},
		editSkuClick(){
			this.addmode = !this.addmode
			this.isdisabled = true
			this.pack1 = this.editForm.pack
			this.qty1 = this.editForm.qty
		},
		saveSkuBtnClick(){
			console.log(this.editForm)
			console.log(this.qty1)
			console.log(this.pack1)
			if(this.qty1 != this.editForm.qty || this.pack1 != this.editForm.pack){
				this.$dialog.confirm({
				  title: '提示',
				  message:'是否将商品'+ this.editForm.itemid + '仓位' + this.editForm.cwno+'的拣货数量设置为'+'\n'
					+'箱装:'+ this.editForm.unit+'，' +'散数：' + this.editForm.qty + ' 箱数：' + this.editForm.pack,
				}).then(() => {
				   this.isdisabled = false
				   this.addmode = !this.addmode
				}).catch(() => {
				    // this.isdisabled = false
				    // this.addmode = !this.addmode
				});
			}else{
				this.isdisabled = false
				this.addmode = !this.addmode
			}
		},
		_getAddressBtn(){
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_jianhuo',
				'i':this.FNULLE([
				'opmode','Y_ANDIAN_qrywz',
				'czyid',this.ryuser.operatorid,
				'kqid', this.ryuser.kqid,
				])
				},'查询位置',true,ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到查询位置")
					console.log(rtn_json_obj)
					if(rtn_json_obj.length > 0){
						_self.addressItem = rtn_json_obj;
						_self.isAddressVisible = true
					}else{
						_self.$toast.fail('暂无位置信息')
					}
				}
			});
		},
		selectAddressClick(row) {
			this.currentIndex = this.addressItem.findIndex(item => item === row)
			this.editForm.hqpbdq = row.hqpbdq
			this.editForm.ck_storeid = row.ck_storeid
			this.editForm.storename = row.storename
			this.editForm.td_no = row.td_no
			this.editForm.rwbill = row.rwbill
			this.isAddressVisible = false
		},
		selectSkuClick(row) {
			this.editForm.ck_storeid = row.ck_storeid
			this.editForm.storename = row.storename
			this.editForm.cwno = row.cwno
			this.editForm.unit = row.unit
			this.editForm.pack = row.pack
			this.editForm.qty = row.qty
			this.editForm.yjtotqty = row.yjtotqty
			this.editForm.subsname = row.subsname
			this.editForm.username = row.username
			this.editForm.barcode = row.barcode
			this.editForm.bill = row.bill
			this.editForm.itemid = row.itemid
			this.editForm.subid = row.subid
			this.editForm.jhrq = row.jhrq
			this.activeIndex = this.skuData.findIndex(item => item === row); //任务序号
      if (this.$refs.scanInput) {
        this.$refs.scanInput.reset()
        this.$nextTick(() => {
          this.$refs.scanInput.focus()
        })
      }
      this.isSkuVisible = false
      this.saveSkuDisabled = true; this.checkedItem = ''; this.checkedCwno = ''; //换商品后要重新扫描
		},

    async _saveSku(){
      if(this.editForm.itemid == this.checkedItem && this.editForm.cwno == this.checkedCwno ){}else{
        this.$toast.fail('请先扫码校验'); return; //需要扫码
      }
      if(this._saveSku_runing){ return ;} //防止重复触发
      await this._saveSku_inner();
    },
    
		async _saveSku_inner(){
			let sendData = {
				'kqid':this.ryuser.kqid,
				'czyid':this.ryuser.operatorid,
				'bill':this.editForm.bill,
				'cwno':this.editForm.cwno,
				'yjtotqty':this.editForm.yjtotqty,
				'pack':this.editForm.pack,
				'qty':this.editForm.qty,
				'unit':this.editForm.unit,
				'itemid':this.editForm.itemid,
				'subid':this.editForm.subid,
				'ck_storeid':this.editForm.ck_storeid,
			}
      var _self = this;
      _self._saveSku_runing = true;
			console.log("传入的值")
			console.log(sendData)
      return new Promise((resolve, reject) => {
				var ldemodata = [{retval:0, errmsg:'返回数据集'},]
				this.MYPOST({
						'method':'dgate',
						'pname':'f_wmsa_y_jianhuo',
						'i':this.FNULLE([
						'opmode','Y_ANDIAN_qritem',
						'kqid', this.ryuser.kqid,
						'czyid',this.ryuser.operatorid,
						'bill',this.editForm.bill,
						'cwno',this.editForm.cwno,
						'yjtotqty',this.editForm.yjtotqty,
						'pack',this.editForm.pack,
						'qty',this.editForm.qty,
						'unit',this.editForm.unit,
						'itemid',this.editForm.itemid,
						'subid',this.editForm.subid,
						'ck_storeid',this.editForm.ck_storeid,
					])
					}, '按店拣货保存',false, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
            _self.$dialog.alert({
              title: '提示',
              message: ret_errmess,
            }).then(() => {
              _self.$store.commit('hideLoading');
              // 重置扫描组件状态
              if (_self.$refs.scanInput) {
                  _self.$refs.scanInput.reset()
                  _self.$nextTick(() => {
                    _self.$refs.scanInput.focus()
                  })
              }
            })
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}
						// _self.skuData = rtn_json_obj
						console.log("按店拣货保存")
						console.log(rtn_json_obj[0])
						if(rtn_json_obj[0].ret_ret == '-1'){
							_self.$toast(rtn_json_obj[0].ret_mess)
              // 重置扫描组件状态
							if (_self.$refs.scanInput) {
								_self.$refs.scanInput.reset()
								_self.$nextTick(() => {
									_self.$refs.scanInput.focus()
								})
							}
						}else{
							_self.$toast(rtn_json_obj[0].ret_mess)
							_self.editForm.ck_storeid 		= ''
							_self.editForm.storename 			= ''
							_self.editForm.cwno 					= ''
							_self.editForm.unit 					= ''
							_self.editForm.pack 					= ''
							_self.editForm.qty 						= ''
							_self.editForm.yjtotqty 			= ''
							_self.editForm.subsname 			= ''
							_self.editForm.username 			= ''
							_self.editForm.barcode 				= ''
							_self.editForm.bill 					= ''
							_self.editForm.itemid 				= ''
							_self.editForm.subid 					= ''
							_self.editForm.jhrq 					= ''
							_self.firstValidation  				= 1 		//又变成第一次扫码
							_self.skuData = [
								{
									subsname	:'',
									ck_storeid	:'',
									storename	:'',
								}
							]
							_self.verifyForm = {
								itemid:'',
								cwno:'',
								barcode:'',
							}
						  _self.errorMessage = ''
							// 重置扫描组件状态
							if (_self.$refs.scanInput) {
								_self.$refs.scanInput.reset()
								_self.$nextTick(() => {
									_self.$refs.scanInput.focus()
								})
							}
              _self.saveSkuDisabled = true; _self.checkedItem = ''; _self.checkedCwno = ''; //按店拣货提交后要重新扫描
              _self.isSubmitVisible = false; 
              // 重新领取任务
              _self.lingquBtn()
              _self.activeIndex = 0
						}
					}
          _self._saveSku_runing = false;
          resolve(1);
			});
      }); //promise
		},
		overBtn(){
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_jianhuo',
					'i':this.FNULLE([
					'opmode','PTJH_jsrq',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'jhrqid', this.editForm.jhrqid,
				])
				}, '确认拣货',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					// _self.skuData = rtn_json_obj
					console.log("得到确认拣货")
					console.log(rtn_json_obj[0])
					if(rtn_json_obj[0].ret_ret == '-1'){
						_self.$toast(rtn_json_obj[0].ret_mess)
					}else{
						_self.$toast(rtn_json_obj[0].ret_mess)
						_self.editForm.jhrqid	= ''
					}
				}
			});
		},
		overRongQiBtnClick(){
			console.log(this.editForm.bill)
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_jianhuo',
					'i':this.FNULLE([
					'opmode','Y_ANDIAN_jsrq_qry',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'bill', this.editForm.bill,
				])
				}, '结束容器',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到结束容器")
					console.log(rtn_json_obj)
					_self.jieshuData = rtn_json_obj
					if(_self.jieshuData.length > 0){
						 _self.$router.push({ path: '/storejieshu', query: {editForm:JSON.stringify(_self.editForm)}})
					}else{
						_self.$dialog.alert({title: '提示',message:'库区'+ _self.ryuser.kqid + '临时容器为空,不能执行结束容器操作! ',confirmButtonColor:'#1989fa'})
					}
				}
			});
		},
    cancelSubmitConfirm(){
      var _self = this;
      this.isSubmitVisible = false;  
      this.saveSkuDisabled = true; _self.checkedItem = ''; _self.checkedCwno = ''; //换商品后要重新扫描
      this.$refs.scanInput.reset()
      this.$nextTick(() => {
        this.$refs.scanInput.focus()
      })
    },
  },
  created() {

  },
  beforeDestroy() {

  },
  mounted() {

  },
};
</script>

<style lang="scss" scoped>
	// 引入公共样式
	@import '@/assets/css/base.scss';
	@import '@/assets/css/input.scss';
	div.zhengtuojianhuo{
		padding-top: 50px;
	}

	.searchGoodsBtn{
		width:120px;
		font-size:18px;
		button{
			width: 100%;
			height: 100%;
			background-color: #EBF3FF;
			border: none;
			color: #1989fa;
		}
	}


  .submitConfirmWrapper{
    width: 80%;
    height: 300px;
    background-color: #fff;
    border-radius: 10px;
    overflow: hidden;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    .submitConfirmHeader{
      width: 100%;
      height:40px;
      background-color: #1989fa;
      display: flex;
      justify-content: center;
      align-items: center;
      color: #fff;
    }
    .submitConfirmContent{
      width: 100%;
      height: 220px;
      .submitConfirmContentLabel{
        width: 100%;
        font-size: 14px;
        color: #000;
        padding:8px;
      }
    }
    .submitConfirmFooter{
      width: 100%;
      height:40px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-top: 1px solid #ccc;
      button{
        width: 50%;
        height: 100%;
        background-color: #1989fa;
        color: #fff;
        border: none;
      }
    }
  }

  // 新增弹窗样式
  .popup-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #f7f8fa;
    .popup-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding:10px 20px;
      border-bottom: 2px solid #ebedf0;
      background: #f7f8fa;
      flex-shrink: 0;
      height:36px;
    }

    .table-container {
      height: calc(100% - 56px);
      overflow: hidden;
      padding:5px;
      background: #f5f7fa;
      width:96%;
      margin: 0 auto;
    }
  }

  // Element UI Table 样式优化
  /deep/ .el-table {
    background-color: transparent;

    th {
      background-color: #1989fa;
      color: #fff;
      font-weight: 500;
      padding:10px 10px;
      border-bottom: 2px solid #e8e8e8;
    }

    td {
      padding: 12px;
      color: #646566;
    }

    tr td{
      padding: 10px !important;
    }

    tr:hover > td {
      background-color: #f5f7fa;

    }

    .current-row > td {
      background-color: #e8f3ff !important;
      color: #1989fa;
    }
  }





</style>
